from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene, get_game
from core.action import Action
#global mixed = 0
#from items.treasure import Treasure

class BallRoom(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.mixed = False
        self.locked = True
#        self.outside = True
        # build list of actions
        #self.add_action(Exit)
        self.add_action(MixDrink)
        # am i to add ones for juice and vodka??
        # self.add_action(UseJuice)
        # self.add_action(UseVodka)
        #self.add_item(UseMary)
        #self.add_item(UseRhett)
        self.add_action(GoGradLounge)
        self.add_action(GoCouncilRoom)
        self.add_action(GoDeanOffice)
     
    # return description of room.
    def get_description(self):
        game = get_game()
        if self.locked:
            if ('mary' in game.get_player().inventory):
                self.locked = False
                desc = "Mary helps you unlock the door. A high ranking executive approaches you and asks you to mix him a screwdriver. You might need ingredients for that."
            elif ('Rhett' in game.get_player().inventory):
                self.locked = False
                desc = "Rhett helps you unlock the door. A high ranking executive approaches you and asks you to mix him a screwdriver. You might need ingredients for that."
            else:
                desc = "You Cannot. Go there... Not without help."
        else: 
            desc = "A high ranking executive approaches you and asks you to mix him a screwdriver. You might need ingredients for that."
        return desc

    
# return image of room
    def get_image(self):
        game = get_game()
        if self.locked:
            if ('mary' in game.get_player().inventory) or ('Rhett' in game.get_player().inventory):
                return 'pekozdance.gif'
            else:
                return 'door.JPG'
        else:
            return 'pekozdance.gif'
        
class BallroomHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return BallRoom

# define actions for this room

    
    # return id of room to enter when action is complete
    def get_destination(self):
        #game = get_game()
        #if (game.history[-1].locked):
            return BallRoom
            
        #else 
        #   return 'ballroom'
    
class MixDrink(Action):
    def __init__(self):
        Action.__init__(self, "Mix Screwdriver")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Mix Screwdriver"
    #mixed = 0
    def do_action(self,game,room,request):
        
        if ('orange juice' in game.get_player().inventory) & ('vodka' in game.get_player().inventory): 
                room.mixed = True
                set_cutscene("Orange +Vodka = Perfection you mixed")                
        else:
                room.mixed = False
                set_cutscene("I do not think you have what you need.")
            
        return
       
        
    # return id of room to enter when action is complete
    def get_destination(self):
        #if mixed == 1:
        #   return 'victory_room'
        #elif mixed == 0: 
        #    return 'ballroom'
        
        if self.room.mixed == False:
            return 'ballroom'
        else:
            return 'victory_room'
            
        return
        # maybe a final room
        
    def is_enabled(self):
        game = get_game()
        if ('mary' in game.get_player().inventory) or ('Rhett' in game.get_player().inventory):
        #if self.room.locked==True:
            return True
        else:
            return False
        
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    
    def get_method(self):
        return "get"

class GoCouncilRoom(Action):
    def __init__(self):
        Action.__init__(self, "GoCouncilRoom")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go to Council Room"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'councilroom'
            
   
    def get_method(self):
        return "get"
    
class GoGradLounge(Action):
    def __init__(self):
        Action.__init__(self, "Grad Lounge")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go to Grad Lounge"
    
    # if treasure is unlocked we go into that room
    # otherwise stay in the basement
    def get_destination(self):
        return 'gradlounge'
    
    def get_method(self):
        return "get"

class GoDeanOffice(Action):
    def __init__(self):
        Action.__init__(self, "GoDeanOffice")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go to Dean Freeman's Office"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'deanoffice'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"